package com.tarena.lbs.business.controller;

import com.github.pagehelper.PageInfo;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.business.pojo.query.BusinessCategoryQuery;
import com.tarena.lbs.business.pojo.vo.BusinessCategoryVO;
import com.tarena.lbs.business.service.BusinessCategoryService;//使用@Reasoure导入了Service的接口
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@Tag(name = "商家分类相关功能接口")
@RestController
public class BusinessCategoryController {
    @Resource
    private BusinessCategoryService businessCategoryService; // 修正：正确的变量名
    @Operation(summary = "查询所有分类---原")
    @GetMapping("/admin/basic/business/category/list/")
    public Result<List<BusinessCategoryVO>> allCategories() {
        try {
            log.info("开始查询所有商家分类");
            //调用Service
            List<BusinessCategoryVO> categoryList = businessCategoryService.getAllCategories(); // 同步修改调用处
            //用Result构造函数封装成功结果，code=0（成功）
            log.info("查询所有商家分类成功，共查询到{}条数据", categoryList.size());
            return new Result<>("0", "查询所有商家分类成功", categoryList);
        } catch (Exception e) {
            //捕获系统异常(数据库连接失败）
            log.error("查询商家分类系统异常", e);
            return Result.fail("-1", "查询商家分类失败：" + e.getMessage());
        }
    }


}
